<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Authing 小程序扫码登录示例</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        #authing__retry {
            margin-top: 12px;
        }
    </style>
</head>
<body>

<script src="https://cdn.jsdelivr.net/npm/authing-js-sdk/dist/authing-js-sdk-browser.min.js"></script>
<script>
    // 初始化 Authing SDK for Web
    const authing = new Authing({
        userPoolId: '5a9fa26cf8635a000185528c'
    });

        // 调用小程序扫码登录的方法，此方法将生成一个用于扫码登录的图片和相关提示信息
        authing.startWXAppScaning({
            // 不自动跳转
            redirect: false,
            
            // 启用获取手机号
            enableFetchPhone: true,
  
            // 扫码成功
            onSuccess(userInfo) {
                alert('扫码成功，请打开控制台查看用户信息')

                console.log(userInfo);
                
                // 存储 token 到 localStorage 中
                localStorage.setItem('token', userInfo.token);
            }
        });
</script>

</body>
</html>
